// 排片--服务层
const schedules = require("../dao/schedulesDao")
//通过影厅ID查询座位
const getSeatByTheaterId= async _id=>await schedules.getSeatByTheaterId(_id)

//添加Seating座位
const addSeating= async objData=>await schedules.addSeating(objData)
const getSeating= async data=>await schedules.getSeating(data)

//通过对应集合名字以及ID查询数据
const getById=async (obj)=>await schedules.getById(obj)

//删除排片
const deleteSchedules=async (_id)=>await schedules.deleteSchedules(_id)

//增加排片
const addData=async(data)=>{
 const {movieId,cinemasId,theaterId,showTime}=data
   const result= await schedules.isHave({movieId,cinemasId,theaterId,showTime})
    if (result.length==0) {
      return  await schedules.addData(data)
    }else{
        return false
    }
}
//更新数据
const updata=async(_id,data)=>await schedules.updata(_id,data);
//DAO中获取电影数据
const getMovies=async()=>await schedules.getMovies();

//DAO中获取影院
const getCinems=async()=>await schedules.getCinems();

//DAO中获取影厅
const getTheaters=async(_id)=>await schedules.getTheaters(_id);

//DAO中获取拍片数据
const getSchedules=async()=>await schedules.getSchedules();

module.exports = {
    addData,getMovies,getCinems,getTheaters,getSchedules,deleteSchedules,updata,getById,getSeatByTheaterId,addSeating,getSeating
}